<!DOCTYPE html>
<script src="./include.js"></script>
<script>
    asyncTest(async (done) => {
        try {
            const httpServer = httpTestServer();
            const url = await httpServer.createEcho("GET", "/test-http-test-server", {
                status: 200,
                headers: {
                    "Access-Control-Allow-Origin": "*",  // necessary when running test using file://...
                    "Access-Control-Expose-Headers": "X-Custom-Header", // tells the browser which headers to expose to JS
                    "Content-Type": "text/plain",
                    "X-Custom-Header": "well hello friends",
                },
                body: "hello world!",
            });
            const result = await fetch(url);
            const headers = result.headers;

            if (headers.get("X-Custom-Header") === "well hello friends") {
                println("PASS");
            } else {
                println("FAIL");
            }
        } catch (err) {
            println("FAIL - " + err);
        }
        done();
    });
</script>
